package com.mspbots.core.wise.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mspbots.core.DefaultBaseMapper;
import com.mspbots.core.wise.model.TenantTimeEntry;
import com.mspbots.core.wise.model.dto.TimeEntryBotReport;
import com.mspbots.cw.request.TenantTimeEntryDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;
import java.util.List;

/**
 * com.mspbots.core.mapper.TenUserTimeLogMapper
 *
 * @author Alex bob(https://github.com/vnobo)
 * @date Created by 2019/6/19
 */
@Mapper
public interface TenantUserTimeEntryMapper extends DefaultBaseMapper<TenantTimeEntry> {

    List<TenantTimeEntry> findAnalysisList(TenantTimeEntryDTO tenUserTimeEntry);

    /**
     * get last one time entry
     *
     * @param tenant tenant id
     * @return time entry
     */
    TenantTimeEntry selectLastOne(@Param("tenant") Long tenant);

    TenantTimeEntryDTO findLastOneById(TenantTimeEntryDTO query);

    Long selectMinId(Long tenantId);

    Long selectMaxId(Long tenantId);

    Long deleteByMinMaxId(Long tenantId, Long timeEntryMinId, Long timeEntryMaxId);

    List<TimeEntryBotReport> botReport(Page<TimeEntryBotReport> page, @Param("query") TimeEntryBotReport queryParams);

    LocalDateTime lastEnteredDate(TimeEntryBotReport query);

    Integer countTimeEntryBot(TimeEntryBotReport query);
}
